package com.twu.biblioteca.domain;

/**
 * User: hwpeng
 * Date: 7/7/13
 * Time: 9:11 AM
 * Project: twu-biblioteca-hwpeng
 */
public class Movie {
    private String title;
    private String year;
    private String director;
    private String rating;

    public Movie(String title, String year, String director, String rating) {
        this.title = title;
        this.year = year;
        this.director = director;
        initializeRating(rating);
    }

    private void initializeRating(String rating) {
        Double rate = -1d;
        try {
            rate = Double.valueOf(rating);
        } catch (NumberFormatException e) {
            this.rating = "N/A";
        }
        if (rate >= 0 && rate <= 10) {
            this.rating = rating;
        }
    }

    public String getTitle() {
        return title;
    }

    public String getYear() {
        return year;
    }

    public String getDirector() {
        return director;
    }

    public String getRating() {
        return rating;
    }

    public void setRating(String rating) {
        this.rating = rating;
    }
}
